/*
 * Copyright (c) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http:  // www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef RECPTPRINTER_SERVICE_RECPTPRINTER_IFACE_H
#define RECPTPRINTER_SERVICE_RECPTPRINTER_IFACE_H

#include <string>
#include <map>

namespace SwanLink {
namespace Finance {

typedef enum __PrintFormatType {
    PRINT_FORMAT_DENSITY = 1,   // 灰度值
    PRINT_FORMAT_BOLD = 2,   // 粗体设置
    PRINT_FORMAT_REVERSE = 3,   // 是否反白
    PRINT_FORMAT_INVERSION = 4,   // 上下倒置
    PRINT_FORMAT_LINETHROUGH = 5,   // 删除线
    PRINT_FORMAT_SIZE = 6,   // 字符大小
    PRINT_FORMAT_ALIGN = 7,   // 对齐方式
    PRINT_FORMAT_ITALIC = 8,   // 是否斜体
    PRINT_FORMAT_HRILOC = 9,   // HRI字符位置,条码
}PrintFormatType;
typedef enum __FormatDensity {
    PF_DENSITY_LIGHT = 0,   // 淡
    PF_DENSITY_MEDIUM = 1,   // 中
    PF_DENSITY_DARK = 2,   // 深
}FormatDensity;
typedef enum __FormatLineThrough {
    PF_LINETHROUGH_NONE = 0,   // 无
    PF_LINETHROUGH_CONTINIOUS = 1,   // 连续的删除线
    PF_LINETHROUGH_BROKEN = 2,   // 断开的删除线
}FormatLineThrough;
typedef enum __FormatSize {
    PF_SIZE_EXTRASMALL = 0,   // 特小
    PF_SIZE_SMALL = 1,   // 小
    PF_SIZE_MEDIUM = 2,   // 中
    PF_SIZE_LARGE = 3,   // 大
    PF_SIZE_EXTRALARGE = 4,   // 特大
}FormatSize;
typedef enum __FormatAlign {
    PF_ALIGN_LEFT = 0,   // 靠左
    PF_ALIGN_CENTER = 1,   // 居中
    PF_ALIGN_RIGHT = 2,   // 靠右
}FormatAlign;
typedef enum __FormatHRILOC {
    PF_HRILOC_NONE = 0,   // 不打印
    PF_HRILOC_UP = 1,   // 条码上方
    PF_HRILOC_DOWN = 2,   // 条码下方
    PF_HRILOC_UPDOWN = 3,   // 条码上下方都有
}FormatHRILOC;
typedef enum __FormatCutMode {
    PF_CUTMODE_ALL = 0,   // 全切
    PF_CUTMODE_HALF = 1   // 半切
}FormatCutMode;
typedef struct __DeviceSpec {
    bool canCutPaper;    // 是否支持切纸
    bool setDensity;      // 是否支持浓度设置
    float width;       // 支持的宽度
}DeviceSpec;

typedef struct __BarcodeSpec {
    int height;
    int narrow;
    int wide;
    int hri;
}BarCodeSpec;

class PrintListener {
 public:
    virtual void OnSuccess(int num, int total) = 0;
    virtual void OnFailed(int code, const std::string& err) = 0;
};

// 状态码
#define ERR_PRINTER_BUSY                -10201      // 打印机忙
#define ERR_PRINTER_OUT_OF_PAPER        -10202      // 打印机缺纸
#define ERR_PRINTER_NO_TASK             -10203      // 打印机没有任务
#define ERR_PRINTER_FORMAT_NOT_SUPPORT  -10204      // 打印格式不支持
#define ERR_PRINTER_VALUE_OUT_RANGE     -10205      // 打印机值超出范围
#define ERR__PRINTER_DATA_PACKET_ERROR  -10206      // 打印数据包格式错误
#define ERR_PRINTER_HW_ERROR            -10207      // 打印机故障
#define ERR_PRINTER_OVERHEATING         -10208      // 打印机过热
#define ERR_PRINTER_LOW_VOLTAGE         -10209      // 打印机电压过低
#define ERR_PRINT_UNFINISHED            -10210      // 打印未完成
#define ERR_PRINTER_DATA_TOO_LONG       -10211      // 数据包过长
#define ERR_PRINTER_DATA_TOO_SHORT      -10212      // 数据包过短
#define ERR__PRINTER_FONT_NOT_EXIST     -10213      // 缺乏字库
#define ERR_PRINTER_CAP_OPEN            -10214      //  开盖
#define ERR_PRINTER_QUERY_ERROR         -10216      //  通信异常
#define ERR_PRINTER_CUT_ERROR           -10217      //  刀异常
#define ERR_PRINTER_CUT_BROKEN          -10218      //  进纸键断开
#define ERR_PRINTER_OFFLINE             -10230      //  脱机状态
#define ERR_PRINTER_ONLINE_ERROR        -10241      // 在线错误
#define ERR_PRINTER_NORMAL              0           //  状态正常

#define DEFINE_ERR(id, err)  {id, err}

const std::map<int, const std::string> g_sErr = {
    DEFINE_ERR(ERR_PRINTER_BUSY,              "打印机忙"),
    DEFINE_ERR(ERR_PRINTER_OUT_OF_PAPER,      "打印机缺纸"),
    DEFINE_ERR(ERR_PRINTER_NO_TASK,           "打印机没有任务"),
    DEFINE_ERR(ERR_PRINTER_FORMAT_NOT_SUPPORT, "打印格式不支持"),
    DEFINE_ERR(ERR_PRINTER_VALUE_OUT_RANGE,   "打印机值超出范围"),
    DEFINE_ERR(ERR__PRINTER_DATA_PACKET_ERROR, "打印数据包格式错误"),
    DEFINE_ERR(ERR_PRINTER_HW_ERROR,           "打印机故障"),
    DEFINE_ERR(ERR_PRINTER_OVERHEATING,        "打印机过热"),
    DEFINE_ERR(ERR_PRINTER_LOW_VOLTAGE,        "打印机电压过低"),
    DEFINE_ERR(ERR_PRINT_UNFINISHED,           "打印未完成"),
    DEFINE_ERR(ERR_PRINTER_DATA_TOO_LONG,      "数据包过长"),
    DEFINE_ERR(ERR_PRINTER_DATA_TOO_SHORT,     "数据包过短"),
    DEFINE_ERR(ERR__PRINTER_FONT_NOT_EXIST,    "缺乏字库"),
    DEFINE_ERR(ERR_PRINTER_CAP_OPEN,           "开盖"),
    DEFINE_ERR(ERR_PRINTER_QUERY_ERROR,        "通信异常"),
    DEFINE_ERR(ERR_PRINTER_CUT_ERROR,          "刀异常"),
    DEFINE_ERR(ERR_PRINTER_CUT_BROKEN,         "进纸键断开"),
    DEFINE_ERR(ERR_PRINTER_OFFLINE,            "脱机状态"),
    DEFINE_ERR(ERR_PRINTER_ONLINE_ERROR,       "在线错误")
};

}   //  namespace Finance
}   //  namespace SwanLink

#endif  // INTERFACES_INNERKITS_NATIVE_INCLUDE_RECPTPRINTER_DEF_H_
